package com.kai.kaiservice.impl;

import com.kai.entity.People;
import com.kai.kaiservice.UserService;
import com.kai.kaispringmvc.annotation.kaiService;

import java.util.ArrayList;
import java.util.List;


/**
 * @author kai
 * @version 1.0
 * @date 2024/7/11
 * @Description
 */
@kaiService
public class UserServiceimpl implements UserService {

    @Override
    public List<People> list_people() {
        //模拟数据，不实现数据库

        List<People> users = new ArrayList<>();
        users.add(new People(1, "kai", "计算机", 50));
        users.add(new People(2, "bushikai", "阳谋", 60));
        return users;
    }

    @Override
    public List<People> findPeopleName(String name) {
        List<People> users = new ArrayList<>();
        users.add(new People(1, "kai", "计算机", 50));
        users.add(new People(2, "bushikai", "阳谋", 60));
        users.add(new People(3, "红豆饼", "也一样", 5));
        users.add(new People(24, "bushi红豆冰", "不", 600));

        //创建集合返回查询到的集合
        List<People> findPeople = new ArrayList<>();
        //遍历users。返回满足条件的
        for (People user : users) {

            if (user.getName().contains(name)) {
                findPeople.add(user);
            }
        }


        return findPeople;
    }

    @Override
    public boolean Login(String name) {
        if (name.equals("红豆饼")) {
            return true;
        } else {
            return false;
        }

    }
}
